package com.wenx.v3system.modular.platform.domain.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 平台用户认证结果DTO
 * 用于在system和auth服务之间传递认证结果信息
 *
 * @author wenx
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PlatformUserAuthResultDto implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 认证是否成功
     */
    private Boolean success;

    /**
     * 认证失败原因
     */
    private String failureReason;

    /**
     * 用户ID
     */
    private Long userId;

    /**
     * 用户名
     */
    private String username;

    /**
     * 邮箱
     */
    private String email;

    /**
     * 手机号
     */
    private String phone;

    /**
     * 用户状态（1-正常，2-锁定，0-禁用）
     */
    private Integer status;

    /**
     * 最后登录时间
     */
    private LocalDateTime lastLoginTime;

    /**
     * 创建成功的认证结果
     */
    public static PlatformUserAuthResultDto success(Long userId, String username, String email, String phone, Integer status, LocalDateTime lastLoginTime) {
        PlatformUserAuthResultDto result = new PlatformUserAuthResultDto();
        result.setSuccess(true);
        result.setUserId(userId);
        result.setUsername(username);
        result.setEmail(email);
        result.setPhone(phone);
        result.setStatus(status);
        result.setLastLoginTime(lastLoginTime);
        return result;
    }

    /**
     * 创建失败的认证结果
     */
    public static PlatformUserAuthResultDto failure(String failureReason) {
        PlatformUserAuthResultDto result = new PlatformUserAuthResultDto();
        result.setSuccess(false);
        result.setFailureReason(failureReason);
        return result;
    }
}